package com.zhu.service.system.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhu.model.pojo.model.system.SysUser;

import com.zhu.service.system.mapper.UserMapper;
import com.zhu.service.system.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhu.model.pojo.model.system.vo.SysUserQueryVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author zhu
 * @since 2022-10-29
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, SysUser> implements IUserService {

    /**
     * 条件分页查询，查询用户列表
     * @param userPage
     * @param userQueryVo
     * @return
     */
    @Override
    public IPage<SysUser> selectPage(Page<SysUser> userPage, SysUserQueryVo userQueryVo) {
        return baseMapper.selectPages(userPage,userQueryVo);
    }

    @Override
    public boolean removeBatch(List<Long> idList) {
        int i = baseMapper.deleteBatchIds(idList);
        if(i>0){
            return true;
        }
        return false;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateStatus(Long id, Integer status) {
        SysUser sysUser = baseMapper.selectById(id);
        sysUser.setStatus(status);
        baseMapper.updateById(sysUser);
    }
}
